package com.oilsoft.module.graphics.ui.model
{
	import com.oilsoft.shared.events.FileUploadEvent;
	import com.oilsoft.shared.vos.contour.Contour;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	import flash.utils.ByteArray;
	
	import mx.controls.Alert;
	import mx.core.ByteArrayAsset;

	public class GraphicModel extends EventDispatcher
	{
		private var dispatcher:IEventDispatcher;
		
		public function GraphicModel(dispatcher:IEventDispatcher){
			this.dispatcher=dispatcher;
		}
		

		public function process():void
		{
			var event:FileUploadEvent = new FileUploadEvent(FileUploadEvent.EXECUTE);
			dispatcher.dispatchEvent(event);
		}

		
		public function clean():void
		{
			contour=null;
		}
		
		public function upload(data:ByteArray,fileName:String):void
		{
			var event:FileUploadEvent = new FileUploadEvent(FileUploadEvent.UPLOAD);
			event.data = data;
			event.fileName = fileName;
			dispatcher.dispatchEvent(event);
			
		}
		
		
		private var _contour:Contour = new Contour();
		
		[Bindable(Event="contourChange")]		
		public function get contour():Contour
		{
			return _contour;
		}

		public function set contour(value:Contour):void
		{
			_contour = value;
			dispatchEvent( new Event( "contourChange" ) );
		}
		
		
	}
}